package chapter07

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test03_MulArray
 * Package: chapter07
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-25
 *          Time: 18:42
 */

//多为数组
object Test03_MulArray {
  def main(args: Array[String]): Unit = {
    //创建一个二维数组 两行三列
    val array = Array.ofDim[Int](2, 3)

    //2.访问元素
    array(0)(2) = 19
    array(1)(0) = 25

    //遍历
    println(array.mkString(","))
    for (i <- 0 until array.length; j <- 0 until array(i).length) {
      println(array(i)(j))
    }

    for (i <- array.indices; j <- array(i).indices) {
      print(array(i)(j) + "\t")
      if (j == array(i).length - 1) println()
    }

    array.foreach(line => line.foreach(println))

    array.foreach( _.foreach(println))


  }
}
